﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Gof_Observer
{
    /// <summary>
    /// Current Condition译:现状
    /// </summary>
    public class CurrentConditionDisplay : Observer,DisplayElement
    {
        private float temperature;
        private float humidity;
        private float pressure; 

        private Subject weatherData;
        public CurrentConditionDisplay(Subject weatherData) {
            this.weatherData = weatherData;
            weatherData.registerObserver(this);
        }

        #region Observer 成员

        public void update(float temp, float humidity, float pressure)
        {
            this.temperature = temp;
            this.humidity = humidity;
            this.pressure = pressure;
            display();
        }

        #endregion

        #region DisplayElement 成员

        public void display()
        {
            Console.WriteLine("温度: " + temperature + " 湿度: " + humidity+" 压强: "+pressure);
        }

        #endregion
    }
}
